package com.example.teesystem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.teesystem.entity.ExamIssue;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
* @author NieYaShi
* @description 针对表【t_exam_issue】的数据库操作Mapper
* @createDate 2022-04-11 19:18:53
* @Entity com.example.teesystem.entity.ExamIssue
*/
@Mapper
public interface ExamIssueMapper extends BaseMapper<ExamIssue> {
    @Select("select * from t_exam_issue where paper_id = #{paperId} and is_delete = 0")
    List<ExamIssue> getExamIssueByPaperId(Integer paperId);

    @Update("update t_exam_issue set score = #{score} where paper_id = #{paperId} and issue_id = #{issueId} and is_delete = 0")
    void updateExamIssueScore(Integer issueId, Integer score, Integer paperId);

    @Select("select issue_id from t_exam_issue where paper_id = #{paperId} and is_delete = 0")
    List<Integer> getIssueListByPaperId(Integer paperId);

    @Select("select SUM(score) FROM t_exam_issue WHERE paper_id = #{paperId} and is_delete = 0")
    Integer getTotalScore(Integer paperId);

    @Update("update t_exam_issue set is_delete = 1 where paper_id = #{paperId} and issue_id = #{issueId}")
    void deleteExamIssue(Integer paperId, Integer issueId);

    @Select("select * from t_exam_issue where issue_id = #{issueId} and is_delete = 0")
    List<ExamIssue> getExamIssueByIssueId(int issueId);

    @Update("update t_exam_issue set is_delete = 1 where paper_id = #{paperId}")
    void deleteByPaperId(Integer paperId);
}




